import 'package:flutter/material.dart';

class BottomWidget extends StatefulWidget {

  final Function callBack;

  const BottomWidget({Key key, this.callBack}) : super(key: key);
  @override
  State<BottomWidget> createState() => _BottomWidgetState();
}

class _BottomWidgetState extends State<BottomWidget> {
  List bottomData = [
    {
      'name': '安徽省合肥市滨湖会展中心',
      'createTime': '9:00',
      'isActive': false,
    },
    {
      'name': '安徽省合肥市滨湖新区万达银座A座',
      'createTime': '10:00',
      'isActive': true,
    }
  ];

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 30, horizontal: 12),
      child: Column(
          children: bottomData.map((item) =>
              GestureDetector(
                onTap: (){
                  setState(() {
                    for(Map i in bottomData){
                      if(i['name'] == item['name']){
                        i['isActive'] = true;
                       widget.callBack(i['name']);
                      }else{
                        i['isActive'] = false;
                      }
                    }


                  });
                },
                child: Container(
                  width: MediaQuery
                      .of(context)
                      .size
                      .width,
                  margin: EdgeInsets.only(bottom: 20),
                  height: 40,
                  alignment: Alignment.centerLeft,
                  padding: EdgeInsets.only(left: 10),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                      color: item['isActive']
                          ? Color.fromRGBO(251, 243, 243, 1)
                          : Color.fromRGBO(249, 249, 249, 1),
                      border: Border.all(
                          color: item['isActive']
                              ? Color.fromRGBO(191, 55, 54, 1)
                              : Color.fromRGBO(221, 221, 221, 1))),
                  child: Text('${item['name']}'),
                ),
              )).toList()
      ),
    );;
  }
}
